
<%@ page import="modelo.VirtualMachineModel" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'VirtualMachineModel.label', default: 'Usuario')}" />
        
		<g:set var="entityNamePlural" 
		       value="${message(code: 'VirtualMachineModel.label.plural', 
		       default: 'Usuariox')}" />
       
       <script type="text/javascript">

       var show = function(option) 
			{    if (option == 'deploy' 
     				|| option == 'migrate' 
     				|| option == 'livemigrate') 
      				{        var thisLevel = document.getElementById('host');
               	    		 thisLevel.style.display = "block";
               				 var thisLevel = document.getElementById('image');
               				 thisLevel.style.display = "none";    } 
     			 else if (option == 'copy') 
     			    {        var thisLevel = document.getElementById('image');
              				 thisLevel.style.display = "block";        
              				 var thisLevel = document.getElementById('host');
              				 thisLevel.style.display = "none";    
     				 } else {        
              				var thisLevel = document.getElementById('host');
              				thisLevel.style.display = "none";
              				var thisLevel = document.getElementById('image');
              				thisLevel.style.display = "none";    
      				}
}



var console = function(id)
{    window.open("/nuvi/virtualM/console/"+id,"Console","resizable=yes,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,width=800,height=620");}
</script>
                     
        <title><g:message code="default.list.label2" args="[entityNamePlural]" /></title>

    </head>
    <body>
        <div class="body">
            <h1><g:message code="default.list.label2" args="[entityNamePlural]" /></h1>
            <g:if test="${flash.message}">
                <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    
                    <thead>
<%--                       <tr>--%>
<%--                           <g:select name="acao.id" from="${modelo.Acao.list()}" optionKey="id" value="${usuarioInstance?.cidade?.id}"  />--%>
<%--									--%>
<%--                                    <g:hasErrors bean="${usuarioInstance}" field="cidade">--%>
<%--                                        <g:eachError bean="${usuarioInstance}" field="cidade">--%>
<%--                                            <font style="color: red;">--%>
<%--                                                <g:message error="${it}"/>--%>
<%--                                            </font>--%>
<%--                                        </g:eachError>--%>
<%--                                    </g:hasErrors>--%>
<%--                           --%>
<%--                       </tr>--%>
                    
                        <tr>
                        
                            <g:sortableColumn property="id" title="${message(code: 'VirtualMachineModel.id.label', default: 'id')}" />
                        
                            <g:sortableColumn property="user" title="${message(code: 'VirtualMachineModel.user.label', default: 'Name')}" />
                        
                            <g:sortableColumn property="name" title="${message(code: 'VirtualMachineModel.name.label', default: 'Nome')}" />
                        
                            <g:sortableColumn property="vmState" title="${message(code: 'VirtualMachineModel.vmState.label', default: 'Endereco')}" />
                        
                            <g:sortableColumn property="lcmState" title="${message(code: 'VirtualMachineModel.lcmState.label', default: 'Endereco')}" />
                                                
                            <g:sortableColumn property="cpu" title="${message(code: 'VirtualMachineModel.cpu.label', default: 'Conta')}" />
                        
                            <g:sortableColumn property="memory" title="${message(code: 'VirtualMachineModel.memory.label', default: 'Senha')}" />
                        
                            <g:sortableColumn property="host" title="${message(code: 'VirtualMachineModel.host.label', default: 'Senha')}" />
                        
                            <g:sortableColumn property="vncPort" title="${message(code: 'VirtualMachineModel.vncPort.label', default: 'Senha')}" />
                        
                            <g:sortableColumn property="time" title="${message(code: 'VirtualMachineModel.tool.label.plural', default: 'Tools')}" />
          
          			        <th>${message(code: 'VirtualMachineModel.time.label', default: 'Senha')}</th>
          
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                    <g:form action="acao">
                    <g:each in="${vmInstanceList}" status="i" var="vmInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td><g:link action="show" id="${vmInstance.id}">${fieldValue(bean: vmInstance, field: "id")}</g:link></td>
                        
                            <td>${fieldValue(bean: vmInstance, field: "user")}</td>
                        
                            <td>${fieldValue(bean: vmInstance, field: "name")}</td>
                        
                            <td> ${fieldValue(bean: vmInstance, field: "vmState")} <g:message code="${fieldValue(bean: vmInstance, field: "vmState")}"/> </td>
                        
                            <td>${fieldValue(bean: vmInstance, field: "lcmState")}</td>
                        
                            <td>${fieldValue(bean: vmInstance, field: "cpu")}</td>
                        
                        	<td>${fieldValue(bean: vmInstance, field: "memory")}</td>
                        
                        	<td>${fieldValue(bean: vmInstance, field: "host")}</td>
                        	
                        	<td>${fieldValue(bean: vmInstance, field: "vncPort")}</td>
                        	
                        	<td><a href="javascript:console('${vmInstance.id}')">[<g:message code="VirtualMachineModel.console.label" />]</a>                 	</td>
                        	
                        	<td>${fieldValue(bean: vmInstance, field: "time")}</td>
          
                            <td><g:checkBox name="action" value="${usuarioInstance?.id}" /></td>
                        
                        </tr>
                    </g:each>
                    </g:form>                     
                    
                    </tbody>
                    
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${vmInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
